﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Seagull.Aop
{
    /// <summary>
    /// 缓存函数的参数解释器。
    /// </summary>
    public class CacheParameterInterpreter : ICacheParameterInterpreter
    {
        /// <summary>
        /// 将参数转换为可识别的key值。
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="method"></param>
        /// <param name="arguments"></param>
        /// <returns></returns>
        public virtual string Key(object instance, MethodBase method, object[] arguments)
        {
            return $"{instance.GetType()!.FullName}.{method.Name}_{System.Text.Json.JsonSerializer.Serialize(arguments)}";
        }
    }
}
